/* This file is apart of rtodo
 * 
 * Copyright (c) 2008, Ryan Capote
 * All rights reserved
 * Released under the BSD license
 */
 #ifndef RTODO_H
 #define RTODO_H
 
 #include <map>
 #include <list>
 #include <string>
 
 #include "task.h"
 
enum SortDir
{
    SORT_NONE,
    SORT_ASCENDING,
    SORT_DESCENDING
};

 /*!
 * Converts the application arguments into a std::list
 * @param argc Argument count
 * @param argList Argument list
 * @return Returns the argument list in a std::list
 */
std::list<std::string> convertArguments(int argc, char *argList[]);

/*!
 * @return Returns a string containing the current working directory
 */
std::string getCwd();

/*!
 * Saves the task list to a textfile specified by the path.
 * @param taskList The list(std::map) of tasks to save.
 * @param path The path to save the text file to including the filename
 */
void save(std::map<int, Task*> taskList, const std::string& path);

/*!
 * @overload void save(std::map<int, Task*> taskList)
 */
void save(std::list<Task*> list, const std::string& path);

/*!
 * Loads the task list from the specified file
 * @param path Path to the todo list including the file
 * @return Returns a list(std::map) of tasks
 */
std::map<int, Task*> loadTodoMap(const std::string& path);

/*!
 * Loads the task list from the specified file
 * @param path Path to the todo list including the filename
 * @return Returns a list(std::list) of tasks
 */
std::list<Task*> loadTodoList(const std::string& path);

/*!
 * Simply outputs a task to the standard output
 */
void view(int id, Task* task);

/*!
 * Prints a list of tasks
 */
void viewTasks(std::map<int, Task*> list);

/*!
 * @overload void viewTasks(std::map<int, Task*> list);
 */
void viewTasks(std::list<Task*> list);

/*!
 * Prints a list of tasks for a specific project
 * @param project The project to view
 * @param list The list of tasks
 */
void viewProject(const std::string& project, std::map<int, Task*> list);

/*! @overload void viewProject(const std::string& project, std::map<int, Task*> list) */
void viewProject(const std::string& project, std::list<Task*>& list);

/*!
 * Prints a list of tasks for a specific context
 * @param context The context to view
 * @param list The list of tasks
 */
void viewContext(const std::string& context, std::map<int, Task*> list);

/*! 
 * @overload void viewContext(const std::string& context, std::map<int, Task*> list) 
 */
void viewContext(const std::string& context, std::list<Task*> list);

/*!
 * Prints a list of next action tasks
 * @param list The list of tasks
 */
void viewNext(std::map<int, Task*> list);

 /*! 
  * @overload void viewNext(std::map<int, Task*> list) 
  */
void viewNext(std::list<Task*> list);
 
/*!
 * Returns a list in order by ascending priority 
 * @param list The list to prioritize
 * @param sort Direction to sort in: SORT_ASCENDING or SORT_DESCENDING
 * @return Returns a std::list of tasks in ascending order by priority
 */
std::list<Task*> prioritizeList(std::map<int, Task*> list, SortDir sort);

/*! 
 * @overload std::list<Task*> prioritizeList(std::map<int, Task*> list, SortDir sort) 
 */
std::list<Task*> prioritizeList(std::list<Task*> list, SortDir sort);

/*!
 * Removes all finished tasks from the list
 * @param list The list to clean
 */
void clearList(std::map<int, Task*>& list);

/*!
 * @overload void clearList(std::map<int, Task*> list)
 */
void clearList(std::list<Task*>& list);

/*!
 * Toggles whether a task is done or not
 * @param list The list of taks
 * @param id The id of the task
 */
 void toggleDone(std::list<Task*>& list, int id);
 
 /*!
  * Toggles whether a task is a next action
  * @param list The list of tasks
  * @param id The id of the task
  */
 void toggleNext(std::list<Task*>& list, int id);

/*!
 * Changes the priority of a specific task
 * @param list The list of tasks
 * @param id The id of the task
 * @param priority The priority to change to
 */
void changePriority(std::list<Task*>& list, int id, int priority);

/*!
 * Changes the category of a specific task
 * @param list The list of tasks
 * @param id The id of the task
 * @param category The category to change it to
 */
void changeContext(std::list<Task*>& list, int id, const std::string& context);

/*!
 * Changes the task's project
 * @param list The list of tasks
 * @param id The id of the task
 * @param project The project to change it to
 */
void changeProject(std::list<Task*>& list, int id, const std::string& project);

/*!
 * Changes the task description
 * @param list The list of tasks
 * @param task The task description
 */
void changeTask(std::list<Task*>& list, int id, const std::string& task);

/*!
 * Adds a task to the list
 * @param filename The path to the file to save the task too, including the filename
 * @param desc The description of the task
 * @param priority The priority of the task
 * @param nextAction Whether the task is a next action
 * @param context The context of the task
 */
void addTask(const std::string& filename, const std::string& desc, int priority, const std::string& context, const std::string& project); 

/*!
 * Permanently deletes a task from the list
 * @param list The list of tasks
 * @param id The id of the task to remove
 */
void deleteTask(std::list<Task*>& list, int id);

#endif
 
